import {
  showLoadingToast,
  showFailToast,
  showSuccessToast,
  showToast,
  allowMultipleToast
} from "vant";

allowMultipleToast();

class Toast {
  static instance: Toast;
  constructor() {}
  static getInstance() {
    if (!this.instance) {
      this.instance = new Toast();
    }
    return this.instance;
  }
  success(message: string) {
    return showSuccessToast({
      message,
      wordBreak: "break-all",
      zIndex: 9999999
    });
  }
  fail(message: string) {
    return showFailToast({
      message,
      wordBreak: "break-all",
      zIndex: 9999999
    });
  }
  info(message: string) {
    return showToast({
      message,
      wordBreak: "break-all",
      className: "toast-info",
      zIndex: 9999999
    });
  }
  loading(message: string = "加载中...") {
    return showLoadingToast({
      message,
      duration: 0,
      forbidClick: true,
      loadingType: "spinner",
      wordBreak: "break-all",
      zIndex: 9999999
    });
  }
}
export const toast = Toast.getInstance();
